<?php
	class Article_model extends MY_Model {
		public $table_name = "article";
		 public function get_All(){
	        $query = $this->db->get($this->table_name);
	        return $query->result();	       
    	}
    	public function count_All(){
    	 	return $this->db->count_all_results($this->table_name);
	        // return $query->result();	       
    	}
        public function get_One($id){
            $query = $this->db->where("id",$id)->get($this->table_name);
            return $query->row();
        }
    	public function get_by_page($page,$page_size){
    		$offset = ($page-1)*$page_size;
    		// $query = $this->db->limit($page_size,$offset)->order_by('id', 'DESC')->get($this->table_name);
    		$query = $this->db->order_by('id', 'DESC')->get($this->table_name,$page_size,$offset);
    		return $query->result(); 
    	}
        // public function add(){
        //     $query = $this->db->get("nav");
        // 	return $query->result();
        // }
        // public function edit($id){
        // 	$query = $this->db->where("id",$id)->get($this->table_name);
        // 	return $query->row();
        // }
        // public function Add_save($data){
        //     $data["create_time"] = time();
        //     $this->db->insert($this->table_name,$data);
        // }
        //  public function Edit_save($id,$data){
        //     $this->db->where("id",$id)->update($this->table_name,$data);
        // }
        // public function Delete($id){
        //     $this->db->where("id",$id)->delete($this->table_name);
        // }
        public function edit_Recommend($id,$value ){
            $data = array(
                "recommend" =>$value,
                );
             $this->db->where("id",$id)->update($this->table_name,$data);
         }
	}
?>